﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.storage.ui {
    import flash.display.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.geom.*;
    import Display.MarketUI.*;
    import Display.InventoryUI.*;
    import flash.text.*;
    import Modules.storage.*;
    import Display.aswingui.*;

    public class StoredItemCell extends InventoryCell {

        public static const CARD_TEXT_MARGIN:int = 2;
        public static const TEXT_HEIGHT:int = 30;
        public static const STATE_OCCUPIED:int = 0;
        public static const STATE_OPEN:int = 1;
        public static const STATE_LOCKED:int = 2;

        protected var m_cellState:int;
        protected var m_storageUnit:BaseStorageUnit;

        public function StoredItemCell(_arg1:LayoutManager=null){
            super(_arg1);
            this.setAssetDict(StorageView.assetDict);
            this.setPreferredHeight(PREFERRED_HEIGHT);
        }
        public static function get PREFERRED_HEIGHT():int{
            return (((Catalog.CARD_HEIGHT + TEXT_HEIGHT) + (2 * CARD_TEXT_MARGIN)));
        }

        override public function setCellValue(_arg1):void{
            this.m_storageUnit = (_arg1.storage as BaseStorageUnit);
            this.m_cellState = _arg1.state;
            if ((_arg1.item is Item)){
                super.setCellValue((_arg1.item as Item));
            } else {
                this.renderEmptyCell(_arg1.item);
            };
        }
        override protected function getCount():int{
            return (this.m_storageUnit.getItemCountByName(this.m_item.name));
        }
        override protected function makeRemoveButtonPanel():JPanel{
            return (null);
        }
        override protected function makeNameAndSetPane():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            ASwingHelper.prepare(this);
            _local1.setMinimumWidth(this.width);
            _local1.setPreferredWidth(this.width);
            _local1.setMaximumWidth(this.width);
            var _local2:AssetPane = ASwingHelper.makeMultilineText(m_item.localizedName, this.width, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.CENTER, 12, 2645358);
            _local1.appendAll(ASwingHelper.verticalStrut(CARD_TEXT_MARGIN), _local2, ASwingHelper.verticalStrut(CARD_TEXT_MARGIN));
            return (_local1);
        }
        protected function renderEmptyCell(_arg1:int):void{
            m_alignmentContainer = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            if (_arg1 == STATE_OPEN){
                m_content = (new (m_assetDict["inventory_card"])() as DisplayObject);
            } else {
                m_content = (new (m_assetDict["inventory_card_locked"])() as DisplayObject);
            };
            this.setPreferredWidth((m_content.width + (CELL_BORDER_GAP * 2)));
            this.setMinimumWidth((m_content.width + (CELL_BORDER_GAP * 2)));
            this.setMaximumWidth((m_content.width + (CELL_BORDER_GAP * 2)));
            m_bgDec = new MarginBackground(m_content);
            m_alignmentContainer.setBackgroundDecorator(m_bgDec);
            m_alignmentContainer.setPreferredSize(new IntDimension(m_content.width, m_content.height));
            m_alignmentContainer.setMinimumSize(new IntDimension(m_content.width, m_content.height));
            m_alignmentContainer.setMaximumSize(new IntDimension(m_content.width, m_content.height));
            m_overlapPane = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.BOTTOM, -(OVERLAP_AMOUNT));
            ASwingHelper.prepare(m_alignmentContainer);
            _local2.append(m_alignmentContainer);
            m_overlapPane.appendAll(_local2, ASwingHelper.verticalStrut(31));
            ASwingHelper.prepare(m_overlapPane);
            this.append(m_overlapPane);
            this.append(ASwingHelper.verticalStrut(20));
            ASwingHelper.prepare(this);
            if (_arg1 == STATE_LOCKED){
                this.alpha = 0.5;
            };
            m_initialized = true;
        }

    }
}//package Modules.storage.ui 
